﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace IntelliTouchMix
{
    public enum Panels
    {
        DECK_A,
        DECK_B,
        LIBRARY,
        INDICATORS,
        RIBBON
    }

    public partial class Util
    {
        public static frmMain formaPrincipal;
        public static FormMain formMain;
        public static Deck deckA;
        public static Deck deckB;
        public static PlayList2 playList;
        public static prueba centerForm;
        public static ComponentBoxForm indicatorForm;

        public static int NONE = -1;

        public static int DECK_A = 0;
        public static int DECK_B = 1;
        public static int LIBRARY = 2;
        public static int INDICATORS = 3;
        public static int RIBBON = 4;

        public static int DECK_WAVE_FULL = 0;
        public static int DECK_WAVE_SCROLL = 1;
        public static int DECK_VOLUME = 2;
        public static int DECK_TEMPO = 3;
        public static int DECK_RATE = 4;

        public static int LIBRARY_EFFECT_BAR = 1;
        public static int LIBRARY_CATEGORY_SONGS = 2;
        public static int LIBRARY_SELECTED = 0;
        public static int LIBRARY_SEARCH = 3;

        public static int INDICATORS_2_FINGERS_CATEGORY = 0;
        public static int INDICATORS_2_FINGERS_EFFECT = 1;
        public static int INDICATORS_3_FINGERS_CATEGORY = 2;
        public static int INDICATORS_3_FINGERS_EFFECT = 3;
        public static int INDICATORS_MATERIAL_CATEGORY = 4;
        public static int INDICATORS_MATERIAL_EFFECT = 5;
        public static int INDICATORS_SAMPLE1_CATEGORY = 6;
        public static int INDICATORS_SAMPLE1_BANK = 7;
        public static int INDICATORS_SAMPLE2_CATEGORY = 8;
        public static int INDICATORS_SAMPLE2_BANK = 9;
        public static int INDICATORS_SCRATCH = 10;
        public static int INDICATORS_SNAP_ONOFF = 11;
        public static int INDICATORS_SNAP_SIZE = 12;

        public static int RIBBON_MUSIC = 0;
        public static int RIBBON_TOUCHMODE = 1;
        public static int RIBBON_MIX = 2;
        public static int RIBBON_INTELLIMIX = 3;
        public static int RIBBON_EFFECTS = 4;
        public static int RIBBON_SETTINGS = 5;

        public static short PLAYER1 = 0;
        public static short PLAYER2 = 1;
        public static short MONITOR_PLAYER = 2;
        public static short PREVIEW_PLAYER = 3;

        public static int CHANGE_CONTROL_WITH_UP_DOWN = 0;
        public static int CHANGE_CONTROL_WITH_LEFT_RIGHT = 1;

        public static Form[] panelForm;

        public static int[] panelControllingType;

        public static Control[][] controllContourPosition;

        public static int reportTimeLimit = 50;
        public static int oneShotTimeLimit = 900;
        public static bool debug = false;

        public static int selectedPanel = LIBRARY;
        public static int[] selectedControl;
        public static int zoomedPanel = NONE;

        public static int SNAP_OFF = 0;
        public static int SNAP_ON = 1;
        public static double SNAP_ON_BEAT = 0;
        public static double SNAP_ON_4 = 4;
        public static double SNAP_ON_8 = 8;
        public static double SNAP_ON_16 = 16;
        public static double SNAP_OFF_0_5 = 0.5;
        public static double SNAP_OFF_1 = 1;
        public static double SNAP_OFF_2 = 2;
        public static int snapStatus = SNAP_ON;
        public static double[] snapValue;
        

        #region AppCreation
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            if (Util.debug)
                Application.Run(new testForm());
            else
               // Application.Run(new Deck());
            //Application.Run(new FormMain());
                //Application.Run(new PlayList());
              // Application.Run(new prueba());
            Application.Run(formaPrincipal=new frmMain());
          //      Application.Run(new Indicators());
        }
        #endregion
        public static  void respAndSet(PictureBox dest, PictureBox src)
        {
            Point l = dest.Location;
            Size s = dest.Size;
            //dest = null;
            //  dest.Click += src.cli;
            dest = src;
            dest.Size = s;
            dest.Location = l;
        }
        public static void init()
        {
            selectedControl = new int[5];
            selectedControl[DECK_A] = DECK_WAVE_SCROLL;
            selectedControl[DECK_B] = DECK_WAVE_SCROLL;
            selectedControl[LIBRARY] = LIBRARY_SELECTED;
            selectedControl[INDICATORS] = INDICATORS_2_FINGERS_EFFECT;
            selectedControl[RIBBON] = RIBBON_MUSIC;
            playList = new PlayList2();
            deckA = new Deck((Int16)DECK_A);
            deckB = new Deck((Int16)DECK_B);
            formMain = new FormMain();
            centerForm = new prueba();
            indicatorForm = new ComponentBoxForm();
            centerForm.TopMost = false;
            centerForm.Show();
            centerForm.TopLevel = false;
            centerForm.Enabled = true;
            formaPrincipal.panelCentral.Controls.Add(centerForm);
            centerForm.Dock = DockStyle.Fill;

            // add events
            respAndSet(Util.deckA.pictureBoxDeckWaveformFull1, Util.formMain.pictureBoxWaveformFull1);

            panelControllingType = new int[selectedControl.Length];
            panelControllingType[DECK_A] = CHANGE_CONTROL_WITH_UP_DOWN;
            panelControllingType[DECK_B] = CHANGE_CONTROL_WITH_UP_DOWN;
            panelControllingType[LIBRARY] = CHANGE_CONTROL_WITH_LEFT_RIGHT;
            panelControllingType[INDICATORS] = CHANGE_CONTROL_WITH_UP_DOWN;
            panelControllingType[RIBBON] = CHANGE_CONTROL_WITH_LEFT_RIGHT;

            snapValue = new double[2];
            snapValue[SNAP_OFF] = SNAP_OFF_1;
            snapValue[SNAP_ON] = SNAP_ON_8;

            controllContourPosition = new Control[selectedControl.Length][];
            controllContourPosition[DECK_A] = new Control[5];
            /*
            controllContourPosition[DECK_A][DECK_WAVE_FULL] = new Rectangle(0, 0, 200, 50);
            controllContourPosition[DECK_A][DECK_WAVE_SCROLL] = new Rectangle(0, 50, 200, 50);
            controllContourPosition[DECK_A][DECK_VOLUME] = new Rectangle(0, 100, 200, 50);
            controllContourPosition[DECK_A][DECK_TEMPO] = new Rectangle(0, 150, 200, 50);
            controllContourPosition[DECK_A][DECK_RATE] = new Rectangle(0, 200, 200, 50);
             * */
            controllContourPosition[DECK_B] = new Control[5];
            /*
            controllContourPosition[DECK_B][DECK_WAVE_FULL] = new Rectangle(200, 0, 200, 50);
            controllContourPosition[DECK_B][DECK_WAVE_SCROLL] = new Rectangle(200, 50, 200, 50);
            controllContourPosition[DECK_B][DECK_VOLUME] = new Rectangle(200, 100, 200, 50);
            controllContourPosition[DECK_B][DECK_TEMPO] = new Rectangle(200, 150, 200, 50);
            controllContourPosition[DECK_B][DECK_RATE] = new Rectangle(200, 200, 200, 50);
             * */
            controllContourPosition[LIBRARY] = new Control[2];
            /*
            controllContourPosition[LIBRARY][LIBRARY_CATEGORY] = new Rectangle(400, 0, 200, 50);
            controllContourPosition[LIBRARY][LIBRARY_CATEGORY_SONGS] = new Rectangle(400, 50, 200, 50);
            controllContourPosition[LIBRARY][LIBRARY_SELECTED] = new Rectangle(400, 100, 200, 50);
            controllContourPosition[LIBRARY][LIBRARY_SEARCH] = new Rectangle(400, 150, 200, 50);
             * */
            controllContourPosition[INDICATORS] = new Control[2];
            controllContourPosition[RIBBON] = new Control[6];

        }
        public static void deSelectAll()
        {
            Util.deckA.panelEx1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            Util.deckB.panelEx1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            Util.playList.panelPlayList.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            Util.indicatorForm.unSelectPanel();// .panelEx1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
            Util.deckA.panelEx1.Refresh();
            Util.deckB.panelEx1.Refresh();
            Util.playList.panelPlayList.Refresh();
            Util.indicatorForm.panelEx1.Refresh();

        }
        public static void dockFormInContainer(Form c)
        {
            c.TopMost = false;
            c.TopLevel = false;
            c.Dock = DockStyle.Fill;
            c.Enabled = true;
            //c.Activate();
            c.Show();
        }

    }
}
